Add gtk_snapshot_push_blur()
authorMatthias Clasen <mclasen@redhat.com>
Sun, 3 Sep 2017 03:50:39 +0000 (23:50 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 4 Sep 2017 18:28:16 +0000 (14:28 -0400)
This function is similar to the other push functions.
This one uses the newly created blur node.

gtk/gtksnapshot.c
gtk/gtksnapshot.h
gtk/gtksnapshotprivate.h

index 0408a70fc81d97135261309fe065ab07fee6e3c5..7f5a1f1db23829637746eb8ac31cff078f599f8a 100644 (file)
@@ -321,6 +321,57 @@ gtk_snapshot_push_opacity (GtkSnapshot *snapshot,
   snapshot->state = state;
 }
 
+static GskRenderNode *
+gtk_snapshot_collect_blur (GtkSnapshotState *state,
+                           GskRenderNode **nodes,
+                           guint           n_nodes,
+                           const char     *name)
+{
+  GskRenderNode *node, *blur_node;
+
+  node = gtk_snapshot_collect_default (state, nodes, n_nodes, name);
+  if (node == NULL)
+    return NULL;
+
+  blur_node = gsk_blur_node_new (node, state->data.blur.radius);
+  if (name)
+    gsk_render_node_set_name (blur_node, name);
+
+  gsk_render_node_unref (node);
+
+  return blur_node;
+}
+
+void
+gtk_snapshot_push_blur (GtkSnapshot *snapshot,
+                        double       radius,
+                        const char  *name,
+                        ...)
+{
+  GtkSnapshotState *state;
+  char *str;
+
+  if (name && snapshot->record_names)
+    {
+      va_list args;
+
+      va_start (args, name);
+      str = g_strdup_vprintf (name, args);
+      va_end (args);
+    }
+  else
+    str = NULL;
+
+  state = gtk_snapshot_state_new (snapshot->state,
+                                  str,
+                                  snapshot->state->clip_region,
+                                  snapshot->state->translate_x,
+                                  snapshot->state->translate_y,
+                                  gtk_snapshot_collect_blur);
+  state->data.blur.radius = radius;
+  snapshot->state = state;
+}
+
 static GskRenderNode *
 gtk_snapshot_collect_color_matrix (GtkSnapshotState *state,
                                    GskRenderNode   **nodes,
index 39ebd25aa0b76932e6a1ed9d9b376a47e3d3bf6c..b5e21ae6eded131448a17b04fc0033a72f7daf87 100644 (file)
@@ -51,6 +51,11 @@ void            gtk_snapshot_push_opacity               (GtkSnapshot
                                                          double                  opacity,
                                                          const char             *name,
                                                          ...) G_GNUC_PRINTF (3, 4);
+GDK_AVAILABLE_IN_3_92
+void            gtk_snapshot_push_blur                  (GtkSnapshot            *snapshot,
+                                                         double                  radius,
+                                                         const char             *name,
+                                                         ...) G_GNUC_PRINTF (3, 4);
 GDK_AVAILABLE_IN_3_90
 void            gtk_snapshot_push_color_matrix          (GtkSnapshot            *snapshot,
                                                          const graphene_matrix_t*color_matrix,
index 3676a10859f7fa949a0881004c7cbabdaf46eb9c..deffbc1aaf44ef17ad46e99269377cd7d3fe949e 100644 (file)
@@ -48,6 +48,9 @@ struct _GtkSnapshotState {
     struct {
       double            opacity;
     } opacity;
+    struct {
+      double            radius;
+    } blur;
     struct {
       graphene_matrix_t matrix;
       graphene_vec4_t offset;